<?php $this->load->view('layout/header'); ?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">商品管理</a></li>
            <li class="active"><a href="javascript:;">订单管理</a></li>
        </ul>
        <div class="product-view-area"><p>订单管理</p></div>
        <div class="order-search">
            <form class="form-horizontal" action="<?php echo site_url('tourismorder/grid');?>" method="get">
                <div class="row">
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单搜索</label>
                            <div class="col-xs-7">
                                <input type="hidden" name="order_status" value="<?php echo $this->input->get('order_status');?>">
                                <input type="text" name="order_search" value="<?php echo $this->input->get('order_search');?>" class="form-control" placeholder="请输入订单编号或宝贝名称">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">创建时间</label>
                            <div class="col-xs-4">
                                 <input type="text" name="start_date" value="<?php echo $this->input->get('start_date');?>" id="start-date" class="form-control laydate-icon" placeholder="开始时间" onclick="laydate({elem:'#start-date',istime: true})">
                            </div>
                            <div class="col-xs-4">
                                <input type="text" name="end_date" value="<?php echo $this->input->get('end_date');?>" id="end-date" class="form-control laydate-icon" placeholder="结束时间" onclick="laydate({elem:'#end-date',istime: true})">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row search-button">
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"> </label>
                            <div class="col-xs-7">
                                <button type="submit" class="btn btn-warning">搜索</button>
                                <button class="btn btn-warning" type="submit" name="excel" value="excel" >导出excel</button>
                                <a href="<?php echo site_url('tourismorder/grid');?>" class="btn btn-default">清除条件</a>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="tourism-order">
            <div class="order-dan">
                <ul class="order-httList">
                    <li <?php if (!$this->input->get('order_status')):?>class="active"<?php endif;?>>
                        <a href="<?php echo site_url('tourismorder/grid').($urlparams ? $urlparams : '') ?>">全部订单 <span><?php //echo array_sum($statusTotal); ?></span></a>
                    </li>
                    <?php foreach ($orderStatus as $key=>$value) :?>
                    <li <?php if ($this->input->get('order_status')==$key):?>class="active"<?php endif;?>>
                        <a href="<?php echo site_url('tourismorder/grid').($urlparams ? $urlparams.'&order_status='.$key : '?order_status='.$key); ?>">
                            <?php echo $value?>订单
                            <span><?php echo isset($statusTotal[ $key]) ? $statusTotal[$key] : 0; ?></span>
                        </a>
                    </li>
                    <?php endforeach;?>
                </ul>
            </div>
            <?php if ($all_rows > 0) :?>
                <table class="table">
                    <thead>
                        <tr>
                            <th>宝贝名称</th>
                            <th>销售价/供应价</th>
                            <th>数量</th>
                            <th>商品操作</th>
                            <th>实际支付</th>
                            <th>交易状态</th>
                            <th>交易操作</th>
                        </tr>
                    </thead>
                    <?php foreach ($list as $item) : ?>
                    <tbody>
                        <tr class="order-num-time">
                            <td>
                                <div class="checkbox">
                                    <label><input type="checkbox" name="sub" class="checkbox-sub">订单号：<?php echo $item['order_sn'] ?></label>
                                </div>
                            </td>
                            <td colspan="3"><p class="text"><?php echo $item['created_at'] ?> 购买者：<?php echo $item['user_name'] ?></p></td>
                            <td colspan="3"></td>
                        </tr>
                        <?php $goods = $item['shop_goods']; $n = count($goods);?>
                        <?php $m = 0;foreach ($goods as $val): ?>
                        <tr>
                            <td class="baobei">
                                <div class="media">
                                    <div class="media-left">
                                        <a target="_blank" href="<?php echo $this->config->wap_base_url.'tourism/goods/info/'.$val->goods_attr_id.'.html' ?>">
                                            <img class="media-object lazy thumbnail" src="skins/images/load.jpg" data-original="<?php echo $this->config->show_image_url($val->goods_image, '300-300') ?>">
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <h4 class="media-heading"><?php echo $val->goods_name ?></h4>
                                        <span><?php echo $val->attribute_value ?></span>
                                    </div>
                                </div>
                            </td>
                            <td class="price">
                                <?php echo $val->shop_price.' / '.$val->supply_price; ?>
                            </td>
                            <td class="quantity">
                                <?php if($val->number == $val->refund_num):?>
                                <p><?php echo $val->number;?></p>
                                <?php else:?>
                                <p><?php echo $val->refund_num;?></p>
                                <?php endif;?>
                            </td>
                            <td>
                                <?php if ($val->number > $val->refund_num): ?>
                                    <p><a href="<?php echo $this->config->gongying_url.'tourismorderrefund/grid.html?order_product_id='.$val->order_product_id;?>">退款详情</a></p>
                                <?php endif;?>
                                <?php if ($val->barter_num > 0): ?>
                                    <p><a href="<?php echo $this->config->gongying_url.'tourismorderexchange/grid.html?order_product_id='.$val->order_product_id;?>">换货详情</a></p>
                                <?php endif;?>
                                <?php if ($item['order_status'] == 6) :?>
                                    <a target="_blank" href="<?php echo site_url('tourismreviews/detail/'.$val->id)?>">查看评价</a>
                                <?php endif;?>
                            </td>
                            <?php if ($m == 0): ?>
                                <td class="border-left" rowspan="<?php echo $n ?>">
                                    <?php $number = '';?>
                                    <?php $refund_num = '';?>
                                    <?php foreach ($item['actually_price'] as $k => $v ): ?>
                                        <?php $number += $v['number'];?>
                                        <?php $refund_num += $v['refund_num'];?>
                                    <?php endforeach ?>
                                    <?php if ($number != $refund_num) :?>
                                        <s class="text-primary">￥<?php echo bcadd($item['actual_price'], $item['transport_cost'], 2);;?></s>
                                        <div class="text-primary">￥<?php echo bcadd($item['order_pay_total'], $item['transport_cost'], 2);?></div>
                                    <?php else :?>
                                        <div class="text-primary">￥<?php echo bcadd($item['actual_price'], $item['transport_cost'], 2);?></div>
                                    <?php endif;?>
                                    	<span>(含运费:￥<?php echo $item['transport_cost'];?>)</span>
                                </td>
                                <td class="border-left" rowspan="<?php echo $n ?>">
                                    <strong class="text-danger"><?php echo $orderStatus[$item['order_status']]?></strong><p></p>
                                    <a target="_blank" href="<?php echo site_url('tourismorder/info/'.$item['order_id']);?>">订单详情</a>
                                </td>
                                
                                <td class="border-left" rowspan="<?php echo $n ?>">
                                    <?php if ($item['order_status'] == 1): ?>
                                        <span>交易取消</span>
                                    <?php elseif ($item['order_status'] == 2):?>
                                        <a href="<?php echo site_url('tourismorder/undo/'.$item['order_id'])?>" onclick="return confirm('确定要取消订单？')">取消订单</a>
                                    <?php elseif ($item['order_status'] == 3):?>
                                        <a target="_blank" href="<?php echo site_url('tourismorder/info/'.$item['order_id'])?>">去发货</a>
                                    <?php elseif ($item['order_status'] == 4):?>
                                        <span>等待买家收货</span>
                                    <?php elseif ($item['order_status'] == 5):?>
                                        <span>等待买家评价</span>
                                    <?php elseif ($item['order_status'] == 6):?>
                                        <span>已评价</span>
                                    <?php endif;?>
                                </td>
                            <?php $m++;endif;?>
                        </tr>
                        <?php endforeach;?>
                    </tbody>
                    <?php endforeach;?>
                </table>
                <nav><?php echo $pg_link;?></nav>
            <?php else: ?>
                <div class="none-data">暂无数据</div>
            <?php endif;?>
        </div>
    </div>
</div>
<?php $this->load->view('layout/footer'); ?>